﻿/// <reference path="../../js/jquery-1.11.1.min.js" />

function DialogBtnSave_OnClick()
{  
    try
    {
		//alert(document.all.txtSURPLUS_OF_QTY.value);
        //return false;
        //$("#lblSHIPMENTS_QTY1_ERR").text("");
        
		$("#lblSHIPMENTS_QTY1_ERR").text("");
		$("#lblSHIPMENTS_DATE1_ERR").text ("");
    	//存檔檢核
    	if($("#txtSHIPMENTS_QTY").val() != "")
    	{
    	    if(isNaN($("#txtSHIPMENTS_QTY").val()))
    		{
    	        $("#lblSHIPMENTS_QTY1_ERR").text ( GetMessageByID("MSG024").text);
    		}
    		else
    		{
    			if($("#txtSHIPMENTS_QTY").val()==0)
				{
					$("#lblSHIPMENTS_QTY1_ERR").text(GetMessageByID("MSG038").text);
				}
				else
				{
					if(Number($("#txtSURPLUS_OF_QTY").val()) < Number($("#txtSHIPMENTS_QTY").val()))
    				{
    						$("#lblSHIPMENTS_QTY1_ERR").text(GetMessageByID("MSG063").text);
    				}
				}
    		  
    		}
    	}
    	else
    	{
    		$("#lblSHIPMENTS_QTY1_ERR").text(GetMessageByID("MSG019").text);
    	}
    	
    	
    	if($("#txtSHIPMENTS_DATE").val() !="")
    	{
    		if(!isDate($("#txtSHIPMENTS_DATE").val()))
			{
				$("#lblSHIPMENTS_DATE1_ERR").text(GetMessageByID("MSG021").text);
			}
			else
			{
				var ServerDate=getServerInfoByClient("date");
				if($("#txtSHIPMENTS_DATE").val() < ServerDate)
				{
					$("#lblSHIPMENTS_DATE1_ERR").text(GetMessageByID("MSG062").text);
				}
			}
    	}
    	else
    	{
    		$("#lblSHIPMENTS_DATE1_ERR").text(GetMessageByID("MSG019").text);
    	}
    	
		
		
    	if ($("#lblSHIPMENTS_DATE1_ERR").text() == "" && $("#lblSHIPMENTS_QTY1_ERR").text() == "")
		{
			return true;
		}
		else
		{
			alert(GetMessageByID("MSG020").text);
			return false;
		}
		
    }
	catch (e)
	{
        alert(e.Message);
        return false;
	}
	finally
	{
	
	}
}

//--------------------------------------------------------------------------------/
//維護程式 - 離開																  /
//功能:離開維護表單																  /
//函式名稱 = DialogBtnExit_OnClick												  /
//--------------------------------------------------------------------------------/
function DialogBtnExit_OnClick()
{
	this.close();
}

//function chknum(v,o)
//{	

//var num = v.value;
//alert(num);
//	if(num>0)
//	{
//		if(num.indexOf(".",0)!=-1)
//		{
//			if(Number(num.length)-(Number(num.indexOf(".",0))+1)>1)
//			{
//				o.innerText=GetMessageByID("MSG041").text;
//			}
//			else
//			{
//				o.innerText="";
//				if(Number(num.length)==(Number(num.indexOf(".",0))+1))
//				{
//					o.innerText=GetMessageByID("MSG042").text;
//				}
//				else
//				{
//					o.innerText="";
//				}
//			}
//		}
//		else
//		{
//			o.innerText="";
//			if(v.value.length>5)
//			{
//				o.innerText=GetMessageByID("MSG043").text;
//			}
			
//		}
//	}
//}

